﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestProject
{
    public partial class FrmLuoXuanXian : Form
    {
        public FrmLuoXuanXian()
        {
            InitializeComponent();
        }


        /*About http://wenku.baidu.com/view/8491a16ca98271fe910ef9a5.html
         * 笛卡尔坐标系 
         * s =  20 * t 
         * angle = 60 + t * 360 *5  
         * x = s * cos (angle) 
         * y = s * sin (angle) z = 0 
        */
        int t1Interval = 200;
        private void FrmLuoXuanXian_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            timer1.Interval = t1Interval;
        }

        int t = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (t1Interval > 50)
            {
                t1Interval -= 20;
                timer1.Interval = t1Interval;
            }
            t += 2;
            int s = 1 * t;
            //double angle = 90 + Math.PI * (t - 90.0) / 180.0*5;
            double angle = 180 + Math.PI * (t - 90.0) / 1000 * 10;
            double x = s * (double)Math.Cos(angle);
            double y = s * (double)Math.Sin(angle);
            using (Graphics g = this.CreateGraphics())
            {
                g.FillEllipse(new SolidBrush(Color.Black),
                    //this.Width / 2 - 20, this.Height / 2 - 20,
                                     (int)x + this.Width / 2, (int)y + this.Height / 2,
                                     80, 80);
            }

            this.richTextBox1.Text += (x + 200).ToString() + ":" + (y + 200).ToString() + "\n";

            //t += 2;
            //int s = 2 * t;
            ////double angle = 90 + Math.PI * (t - 90.0) / 180.0*5;
            //double angle = 90 + Math.PI * (t - 90.0) / 180.0 * 10;
            //double x = s * (double)Math.Cos(angle); 
            //double y = s * (double)Math.Sin(angle);
            //using (Graphics g = this.CreateGraphics())
            //{
            //    g.FillEllipse(new SolidBrush(Color.Black),
            //                         //this.Width / 2 - 20, this.Height / 2 - 20,
            //                         (int)x+this.Width/2,(int)y+this.Height/2,
            //                         80, 80);
            //}

            //this.richTextBox1.Text += (x+200).ToString()+":"+(y+200).ToString()+"\n";
        }
        /// <summary>
        /// 靶形状
        /// </summary>
        private void ddd()
        {
            if (t1Interval > 50)
            {
                t1Interval -= 20;
                timer1.Interval = t1Interval;
            }
            t += 2;
            int s = 1 * t;
            //double angle = 90 + Math.PI * (t - 90.0) / 180.0*5;
            double angle = 180 + Math.PI * (t - 90.0) / 720 * 10;
            double x = s * (double)Math.Cos(angle);
            double y = s * (double)Math.Sin(angle);
            using (Graphics g = this.CreateGraphics())
            {
                g.FillEllipse(new SolidBrush(Color.Black),
                    //this.Width / 2 - 20, this.Height / 2 - 20,
                                     (int)x + this.Width / 2, (int)y + this.Height / 2,
                                     80, 80);
            }

            this.richTextBox1.Text += (x + 200).ToString() + ":" + (y + 200).ToString() + "\n";
        }

        private void FrmLuoXuanXian_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = this.CreateGraphics())
            {
                g.FillEllipse(new SolidBrush(Color.Black),
                                     this.Width / 2 - 20, this.Height / 2 - 20,
                                     40, 40);
            }
        }
    }
}
